package com.ctshk.app.certificate.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.certificate.dto.AppointmentHkMacauBridgeDTO;
import com.ctshk.rpc.certificate.dto.CertificateHkMacauBridgeDTO;
import com.ctshk.rpc.certificate.req.CertificateHkMacauBridgeReq;
import com.ctshk.rpc.certificate.req.ProcCommonCertificateReq;
import com.ctshk.rpc.certificate.req.QueryHkMacauBridgeReq;
import com.ctshk.rpc.certificate.service.ICertificateHkMacauBridgeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 粤港经港珠澳大桥口口岸入出内地商务车辆牌证业务 前端控制器
 * </p>
 *
 * @author 谢诗宏
 * @since 2021-03-25
 */
@Api(value = "粤港经港珠澳大桥口岸入出内地商务车辆牌证",tags = "粤港经港珠澳大桥口岸入出内地商务车辆牌证")
@RestController
@RequestMapping("/certificate-hk-macau-bridge")
public class CertificateHkMacauBridgeController extends BaseController {
    @DubboReference
    private ICertificateHkMacauBridgeService hkMacauBridgeService;

    @ApiOperation(value = "粤港经港珠澳大桥口口岸入出内地商务车辆牌证登记", notes = "粤港经港珠澳大桥口口岸入出内地商务车辆牌证登记")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.ADD, operTitle = "粤港经港珠澳大桥口口岸入出内地商务车辆牌证登记", operDesc = "粤港经港珠澳大桥口口岸入出内地商务车辆牌证登记")
    @PostMapping("/save")
    public Result saveHkMacauBridge(@RequestBody @Valid CertificateHkMacauBridgeReq certificateHkMacauBridgeReq) {
        Long userId = getCurrentUser(getRequest()).getId();
        return hkMacauBridgeService.saveHkMacauBridge(certificateHkMacauBridgeReq, userId);
    }

    @ApiOperation(value = "粤港经港珠澳大桥口口岸入出内地商务车辆牌证信息详情", notes = "粤港经港珠澳大桥口口岸入出内地商务车辆牌证信息详情")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "查询证件信息详情", operDesc = "查询证件信息详情")
    @GetMapping(value = "/detail")
    public Result<CertificateHkMacauBridgeDTO> queryDetail(@RequestParam(value = "id") Long id) {
        return Result.success(hkMacauBridgeService.queryDetail(id));
    }

    @ApiOperation(value = "修改粤港经港珠澳大桥口口岸入出内地商务车辆牌证信息", notes = "修改粤港经港珠澳大桥口口岸入出内地商务车辆牌证信息")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.UPDATE, operTitle = "修改证件信息", operDesc = "修改证件信息")
    @PostMapping("/update")
    public Result updateHkMacauBridge(@RequestBody @Valid CertificateHkMacauBridgeReq certificateHkMacauBridgeReq) {
        Long userId = getCurrentUser(getRequest()).getId();
        return hkMacauBridgeService.updateHkMacauBridge(certificateHkMacauBridgeReq, userId);
    }

    @ApiOperation(value = "处理粤港经港珠澳大桥口口岸入出内地商务车辆牌证预约信息", notes = "处理粤港经港珠澳大桥口口岸入出内地商务车辆牌证预约信息")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.UPDATE, operTitle = "处理粤港经港珠澳大桥口口岸入出内地商务车辆牌证预约信息", operDesc = "处理粤港经港珠澳大桥口口岸入出内地商务车辆牌证预约信息")
    @PostMapping("/proc-reserve")
    public Result procReserveHkMacauBridge(@RequestBody @Valid ProcCommonCertificateReq procReserveHkMacauBridgeReq) {
        Long userId = getCurrentUser(getRequest()).getId();
        return hkMacauBridgeService.procReserveHkMacauBridge(procReserveHkMacauBridgeReq, userId);
    }

    @ApiOperation(value = "预约信息(核对, 完成预约, 查询预约状态结果)", notes = "预约信息(核对, 完成预约, 查询预约状态结果)")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "查询预约信息", operDesc = "查询预约信息")
    @GetMapping(value = "/query-appointment-info")
    public Result<AppointmentHkMacauBridgeDTO> queryAppointmentInfo(@RequestBody @Valid QueryHkMacauBridgeReq queryAppointmentInfoReq) {
        Long userId = getCurrentUser(getRequest()).getId();
        return hkMacauBridgeService.queryAppointmentInfo(queryAppointmentInfoReq, userId);
    }

    @ApiOperation(value = "取消预约", notes = "取消预约")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "取消预约", operDesc = "取消预约")
    @GetMapping(value = "/cancel-appointment")
    public Result cancelAppointment(@RequestParam(value = "id") Long id) {
        Long userId = getCurrentUser(getRequest()).getId();
        return hkMacauBridgeService.cancelAppointment(id, userId);
    }
}
